<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>快递管理系统</title>
    <meta name="Copyright" content="Douco Design."/>
    <link href="css/public.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/global.js"></script>
    <script type="text/javascript" src="js/jquery.autotextarea.js"></script>
</head>
<body>

<div id="dcWrap">
    <div id="dcHead">
        <div id="head">
            <div class="logo"><a href="index.jsp"><img width="100px"
                                                       height="25px" src="images/dclogo.gif"
                                                       alt="logo"></a></div>
            <div class="nav">
                <ul class="navRight">
                    <li class="M noLeft"><a
                            href="JavaScript:void(0);">您好，admin</a>
                        <div class="drop mUser">
                            <a href="password.jsp">修改密码</a>
                        </div>
                    </li>
                    <li class="noRight"><a
                            href="login.html">退出</a></li>
                </ul>
            </div>
        </div>
    </div>
    <!-- dcHead 结束 -->
    <div id="dcLeft">
        <div id="menu">
            <ul class="top">
                <li><a href="index.jsp"><i
                        class="home"></i><em>管理首页</em></a></li>
            </ul>
            <ul>
                <li><a href="password.jsp"><i
                        class="system"></i><em>修改密码</em></a></li>
                <li><a href="list.jsp"><i
                        class="nav"></i><em>快递管理</em></a></li>
            </ul>
        </div>
    </div>
    <div id="dcMain">
        <!-- 当前位置 -->
        <div id="urHere">快递管理系统<b>></b><strong>快递列表</strong></div>
        <div class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
            <h3><a href="/DeliveryServletToAddPage" class="actionBtn add">添加快递</a>快递列表</h3>
            <!--
            本阶段不实现!!
            <div class="filter">
                <form action="#" method="post">
                    物流公司
                    <select name="cat_id">
                        <option value>请选择</option>
                        <option value="1"> 申通快递</option>
                        <option value="2"> 圆通快递</option>
                        <option value="2"> 韵达快递</option>
                    </select>
                    收件人手机号 <input name="keyword" type="text"
                        class="inpMain" value size="20" />
                    签收状态 <select name="cat_id">
                        <option value>请选择</option>
                        <option value="1">已签收</option>
                        <option value="2"> 未签收</option>

                    </select>
                    <input name="submit" class="btnGray" type="submit"
                        value="筛选" />
                </form>

            </div> -->
            <div id="list">
                <table width="100%" border="0" cellpadding="8"
                       cellspacing="0" class="tableBasic">
                    <tr>
                        <th width="80" align="center">编号</th>
                        <th width="200" align="center">物流公司</th>
                        <th width="80" align="center">收件人</th>
                        <th width="80" align="center">手机号</th>
                        <th width="160" align="center">送达日期</th>
                        <th align="center">地址</th>
                        <th width="100" align="center">签收状态</th>
                        <th width="300" align="center">操作</th>
                    </tr>
                    <c:if test="${empty requestScope.deliveryList}">
                        <tr>
                            <td align="center" colspan="8">抱歉！没有任何数据可以显示！</td>
                        </tr>
                    </c:if>
                    <c:if test="${not empty requestScope.deliveryList}">
                        <c:forEach items="${requestScope.deliveryList}" var="delivery">
                            <tr>
                                <td align="center">${delivery.id}</td>
                                <td>${delivery.company.companyName}</td>
                                <td align="center">${delivery.deliveryName}</td>
                                <td align="center">${delivery.phone}</td>
                                <td align="center">${delivery.sendTime}</td>
                                <td align="center">${delivery.address}</td>
                                <td align="center">${delivery.state == 0 ? "未签收" : "已签收"}</td>
                                <td align="center">
                                    <a href="/DeliveryServletToEditPage?id=${delivery.id}">编辑</a> | <a class="delAnchor" href="/DeliveryServletRemove?id=${delivery.id}">删除</a>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:if>
                </table>
            </div>
            <div class="clear"></div>
            <div class="pager"><a href="article.php?page=1">第一页</a>
                <a href="article.php?page=1"> 上一页</a> <a
                        href="article.php?page=1">下一页</a> <a
                        href="article.php?page=1">最末页</a></div>
        </div>
    </div>
    <div class="clear"></div>
    <div id="dcFooter">
        <div id="footer">
            <div class="line"></div>
            <ul>
                版权所有 © 2024-2025 尚硅谷教育，并保留所有权利。
            </ul>
        </div>
    </div><!-- dcFooter 结束 -->
    <div class="clear"></div>
</div>
<script type="text/javascript">

    onload = function () {
        document.forms['action'].reset();
    }

    function douAction() {
        var frm = document.forms['action'];

        frm.elements['new_cat_id'].style.display = frm.elements['action'].value == 'category_move' ? '' : 'none';
    }

</script>
</body>
<script type="text/javascript">
    // <a class="delAnchor" href="/DeliveryServletRemove">删除</a>
    let anchorEleArr = document.getElementsByClassName("delAnchor");

    // 遍历元素数组
    for (let i = 0; i < anchorEleArr.length; i++) {
        // 获取元素
        let anchorEle = anchorEleArr[i];
        // 添加点击事件
        anchorEle.onclick = function () {
            // 获取当前记录的相关信息，便于确认
            // [1]获取超链接的父元素的父元素
            let trEle = this.parentNode.parentNode;

            // [2]获取 tr 下所有子元素，从下标 2 获取收件人姓名、下标 5 获取收件地址
            let deliveryName = trEle.children[2].innerText;
            let address = trEle.children[5].innerText;
            console.log(deliveryName)
            console.log(address)

            // 弹出确认框
            let confirmResult = confirm("您真的要删除"+deliveryName+","+address+"这条记录吗？");

            // 如果用户点击了取消，那么就阻止控件的默认行为
            if (!confirmResult) {
                event.preventDefault();
            }
        }
    }
</script>
</html>